package com.paotui.controller;

import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.paotui.common.R;
import com.paotui.pojo.Users_address;
import com.paotui.service.impl.UsersAddressServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/users/address/list")
public class UsersAddressListController extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        UsersAddressServiceImpl impl = new UsersAddressServiceImpl();
        int usersID = Integer.parseInt(request.getParameter("UsersID"));
        QueryWrapper<Users_address> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("UsersID",usersID);
        List<Users_address> list = impl.list(queryWrapper);
        R r = R.success("查询成功！",list);
        response.getWriter().write(JSONUtil.toJsonStr(r));

    }
}
